package com.dataextend.controller;


import com.alibaba.fastjson.JSONObject;
import com.dataextend.dto.ResultSegment;
import com.dataextend.entity.*;
import com.dataextend.service.AnalysisModelSaveService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 *  分析模型列表页
 */
@RestController
@RequestMapping("/v1/modelList")
@CrossOrigin(origins={"http://localhost:8080"},allowCredentials="true")
public class AnalysisModelListController {
    @Autowired
    private AnalysisModelSaveService analysisModelSaveService;


    /**
     *  事件模型 - 添加
     */
    @ApiOperation(value = "事件模型-添加")
    @RequestMapping(value = "/eventAnalysisModel", method = RequestMethod.POST)
    public JSONObject eventAnalysisModel(@RequestBody EventAnalysisModel eventAnalysisModel){
        return analysisModelSaveService.eventAnalysisModel(eventAnalysisModel);
    }

    /**
     *  事件模型- 列表
     */
    @ApiOperation(value = "事件模型-列表")
    @RequestMapping(value = "/listEventModel", method = RequestMethod.POST)
    public ResultSegment listEventModel(){
        JSONObject map = analysisModelSaveService.listEventModel();
        return new ResultSegment(true, 1, "查询成功", map);
    }

    /**
     *  事件模型- 删除
     */
    @ApiOperation(value = "事件模型-删除")
    @RequestMapping(value = "/deleteEventModel", method = RequestMethod.POST)
    public JSONObject deleteEventModel(@RequestParam(value = "modelId", required = false) String modelId){
        return analysisModelSaveService.deleteEventModel(modelId);
    }



    /**
     *  转化漏斗分析- 添加
     */
    @ApiOperation(value = "转化漏斗分析-添加")
    @RequestMapping(value = "/hopperAnalysisModel", method = RequestMethod.POST)
    public JSONObject hopperAnalysisModel(@RequestBody HopperAnalysisModel hopperAnalysisModel){
        return analysisModelSaveService.hopperAnalysisModel(hopperAnalysisModel);
    }

    /**
     *  转化漏斗分析- 列表
     */
    @ApiOperation(value = "转化漏斗分析-列表")
    @RequestMapping(value = "/listHopperModel", method = RequestMethod.POST)
    public ResultSegment listHopperModel(){
        JSONObject map = analysisModelSaveService.listHopperModel();
        return new ResultSegment(true, 1, "查询成功", map);
    }

    /**
     *  转化漏斗分析- 删除
     */
    @ApiOperation(value = "转化漏斗分析-删除")
    @RequestMapping(value = "/deleteHopperModel", method = RequestMethod.POST)
    public JSONObject deleteHopperModel(@RequestParam(value = "modelId", required = false) String modelId){
        return analysisModelSaveService.deleteHopperModel(modelId);
    }



    /**
     *  留存分析- 添加
     */
    @ApiOperation(value = "留存分析-添加")
    @RequestMapping(value = "/remainAnalysisModel", method = RequestMethod.POST)
    public JSONObject remainAnalysisModel(@RequestBody RemainAnalysisModel remainAnalysisModel){
        return analysisModelSaveService.remainAnalysisModel(remainAnalysisModel);
    }

    /**
     *  留存分析- 列表
     */
    @ApiOperation(value = "留存分析-列表")
    @RequestMapping(value = "/listRemainModel", method = RequestMethod.POST)
    public ResultSegment listRemainModel(){
        JSONObject map = analysisModelSaveService.listRemainModel();
        return new ResultSegment(true, 1, "查询成功", map);
    }

    /**
     *  留存分析- 删除
     */
    @ApiOperation(value = "留存分析-删除")
    @RequestMapping(value = "/deleteRemainModel", method = RequestMethod.POST)
    public JSONObject deleteRemainModel(@RequestParam(value = "modelId", required = false) String modelId){
        return analysisModelSaveService.deleteRemainModel(modelId);
    }



    /**
     *  分布分析- 添加
     */
    @ApiOperation(value = "分布分析-添加")
    @RequestMapping(value = "/distributeAnalysisModel", method = RequestMethod.POST)
    public JSONObject distributeAnalysisModel(@RequestBody DistributeAnalysisModel distributeAnalysisModel){
        return analysisModelSaveService.distributeAnalysisModel(distributeAnalysisModel);
    }

    /**
     *  分布分析- 列表
     */
    @ApiOperation(value = "分布分析-列表")
    @RequestMapping(value = "/listDistributeModel", method = RequestMethod.POST)
    public ResultSegment listDistributeModel(){
        JSONObject map = analysisModelSaveService.listDistributeModel();
        return new ResultSegment(true, 1, "查询成功", map);
    }

    /**
     *  分布分析- 删除
     */
    @ApiOperation(value = "分布分析-删除")
    @RequestMapping(value = "/deleteDistributeModel", method = RequestMethod.POST)
    public JSONObject deleteDistributeModel(@RequestParam(value = "modelId", required = false) String modelId){
        return analysisModelSaveService.deleteDistributeModel(modelId);
    }



}
